package com.example.systemtimeclient.controller;

import com.example.systemtimeclient.service.TransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;


import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author
 * @since 2019-05-17
 */
@Controller
@RequestMapping("/time")
public class TimeController {
    @Autowired
    TransferService transferService;

    @PostMapping("/getTime")
    @ResponseBody
    public Time getTime() {
        return new Time();
    }

    @PostMapping("/updateTime")
    @ResponseBody
    public String updateTime() {
        transferService.alarmEventDay();
        return "ojbk";
    }
}

class Time{
     String time;
    String date;
    Time(){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        this.time = df.format(new Date());
        SimpleDateFormat df1 = new SimpleDateFormat("HH:mm:ss");
        this.date = df1.format(new Date());
    }

    public String getTime() {
        return time;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getDate() {
        return date;
    }
}